<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});


Route::get('posts','PostController@index')->name('posts');
Route::get('posts/create','PostController@create');
Route::get('posts/{post}/edit','PostController@edit');
Route::put('posts/{post}','PostController@update');
Route::get('posts/{post}','PostController@show');
Route::post('posts','PostController@store');
Route::post('posts/image/upload', '\App\Http\Controllers\PostController@imageUpload');
Route::get('posts/{post}/delete','PostController@delect');
Route::post('posts/{post}/review','PostController@review');
Route::get('posts/{post}/like','PostController@like');
Route::get('posts/{post}/unlike','PostController@unLike');




Route::get('register','RegisterController@index');
Route::post('register','RegisterController@register');
Route::get('login','LoginController@index');
Route::post('login','LoginController@login');
Route::get('logout','LoginController@logout');


//个人中心
Route::get('user/{user}','UserController@show');
Route::post('user/{user}/fan','UserController@fan');
Route::post('user/{user}/unfan','UserController@unfan');


//admin
Route::group(['prefix'=>'admin'],function(){
	Route::get('login','Admin\LoginController@index');
	Route::post('login','Admin\LoginController@login');
	Route::get('logout','Admin\LoginController@logout');

	Route::group(['middleware'=>'auth:admins'],function(){
		Route::get('home/index','Admin\HomeController@index');

		Route::get('users','Admin\UserController@index');
		Route::get('users/create','Admin\UserController@create');
		Route::post('users/store','Admin\UserController@store');
		Route::get('users/{user}/role','Admin\UserController@role');
		Route::post('users/{user}/role','Admin\UserController@storeRole');


		Route::get('posts','Admin\PostController@index');
		Route::post('posts/{post}/status','Admin\PostController@status');

		//角色
		Route::get('roles','Admin\RoleController@index');
		Route::get('roles/create','Admin\RoleController@create');
		Route::post('roles/store','Admin\RoleController@store');
		Route::get('/roles/{role}/permission', 'Admin\RoleController@permission');
        Route::post('/roles/{role}/permission', 'Admin\RoleController@storePermission');

		//权限
		Route::get('permissions','Admin\PermissionController@index');
		Route::get('permissions/create','Admin\PermissionController@create');
		Route::post('permissions/store','Admin\PermissionController@store');
	});
});
